<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/12/27 10:48
 * Desc:
 */
class Service_Ferry_Ticket_StockLimit_Card extends Contract_Ticket_StockLimit_Stock
{
    public function handle($ticket_info, $stock, $use_date, $params = array())
    {
        if (St_Functions::is_normal_app_install('system_card') && !empty($params['member_card_id'])) {
            $params['product_id'] = $ticket_info['ferryid'];
            $params['type_id'] = Model_Ferry::$typeid;
            $params['suit_id'] = $ticket_info['id'];
            $params['start_date'] = $use_date;

            $number = Model_Card::member_card_product_detail($params);
            $stock = min($number, $stock);
        }

        if ($stock == 0) {
            return $stock;
        }

        return $this->next->handle($ticket_info, $stock, $use_date, $params);
    }
}